package Meituan;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.List;

/**
 * @author: leiwenkang
 * @date: 2020/6/22
 * @time: 11:57
 */
public class FileOriginGen {
    public static void main(String[] args) {
        String pathName = "/Users/leiwenkang/Downloads/project/src/Offer-study/src/main/resources/brand_origin";
        genOriginFile(pathName);
    }

    public static void genOriginFile(String pathName) {
        InputStreamReader input = null;
        BufferedReader br = null;
        try {
            File file = new File(pathName);
            input = new InputStreamReader(new FileInputStream(file));
            br = new BufferedReader(input);

            String line;
            List<String> contents = Lists.newArrayList();
            while(null != (line = br.readLine())) {
                if (StringUtils.isNotBlank(line)) {
                    contents.add(line);
                }
            }

            for (int i = 0; i < contents.size(); i++) {
                System.out.print(contents.get(i));
                System.out.print(" ");
                if ((i + 1) % 6 == 0) {
                    System.out.println();
                }
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (input != null) {
                    input.close();
                }

                if (br != null) {
                    br.close();
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
